from goods.models import GoodsChannel


def get_breadcrumb(cat3):
    """获取面包屑导航返回字典"""
    # 返回前端 {cat1:,cate2:,cat3:...}
    cat1 = cat3.parent.parent
    # 给cat1从goodchannel拿到url属性,
    cat1.url = cat1.goodschannel_set.all()[0].url
    breadcrumb = {
        'cat1': cat1,
        'cat1.url':cat1.url,
        'cat2': cat3.parent,
        'cat3': cat3
    }
    return breadcrumb